module.exports = {
    render: function () {


        var select1 = new icu.formElement.select({
            verify: {
                text: '性别',
                rules: ['notNull']
            },
            data: 'OptionSide:Gender',
        });
        this.$el.find('#select1').append(select1.html);
        this.$el.find('#selectbutton1_0').click(() => {
            select1.get((emsg, value) => {
                if (emsg) {
                    icu.alert.error({ text: emsg });
                } else {
                    icu.alert.normal({ text: value });
                };
            });
        })
        this.$el.find('#selectbutton1_1').click(() => {
            select1.set('0');
        })
        this.$el.find('#selectbutton1_2').click(() => {
            select1.clear();
        });


        var select2 = new icu.formElement.select();
        this.$el.find('#select2').append(select2.html);
        // 异步赋值（通过数组）
        this.$el.find('#selectbutton2_0').click(() => {
            select2.setData([{ "label": "test1", "value": "test1" }, { "label": "test2", "value": "test2" }]);
        });
        // 异步赋值（通过字典项）
        this.$el.find('#selectbutton2_1').click(() => {
            select2.setData('OptionSide:Gender');
        });

        var select3 = new icu.formElement.select({
            setKey: 'id', // 改变赋值时所选择的对象
            getKey: 'object', // 特殊关键字 取值时取得select所选对象 
            showKey: 'name', // 显示用字段
            data: [
                { "name": "name1", "id": "id1" },
                { "name": "name2", "id": "id2" }
            ]
        });
        this.$el.find('#select3').append(select3.html);
        // 取值方法
        this.$el.find('#selectbutton3_0').click(() => {
            select3.get((emsg, value) => {
                if (emsg) {
                    icu.alert.error({ text: value });
                } else {
                    icu.alert.normal({ text: JSON.stringify(value) });
                };
            });
        });
        // 赋值方法
        this.$el.find('#selectbutton3_1').click(() => {
            select3.set('id2');
        });
    },
};